package com.twu.biblioteca.models;

import com.twu.biblioteca.exceptions.UnavailableBookException;

public class Book {
    private int id;
    private String title;
    private boolean available;

    public Book(int id, String title) {
        this.id = id;
        this.title = title;
        available = true;
    }

    public int getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public boolean isAvailable() {
        return available;
    }

    public void reserve() throws UnavailableBookException {
        if (!available) {
            throw new UnavailableBookException("Sorry we don't have that book yet.");
        }
        available = false;
    }

}
